<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Easy
  </div>
  <div>
   <h1 class="question_title">
    1054. Complement of Base 10 Integer
   </h1>
   <p>
    Every non-negative integer
    <code>
     N
    </code>
    &nbsp;has a binary representation.&nbsp; For example,&nbsp;
    <code>
     5
    </code>
    can be represented as
    <code>
     "101"
    </code>
    &nbsp;in binary,
    <code>
     11
    </code>
    as
    <code>
     "1011"
    </code>
    &nbsp;in binary, and so on.&nbsp; Note that except for
    <code>
     N = 0
    </code>
    , there are no leading zeroes in any&nbsp;binary representation.
   </p>
   <p>
    The
    <em>
     complement
    </em>
    &nbsp;of a binary representation&nbsp;is the number in binary you get when changing every
    <code>
     1
    </code>
    to a
    <code>
     0
    </code>
    and
    <code>
     0
    </code>
    to a
    <code>
     1
    </code>
    .&nbsp; For example, the complement of
    <code>
     "101"
    </code>
    in binary is
    <code>
     "010"
    </code>
    in binary.
   </p>
   <p>
    For a given number
    <code>
     N
    </code>
    in base-10, return the complement of it's binary representation as a&nbsp;base-10 integer.
   </p>
   <p>
    &nbsp;
   </p>
   <ol>
   </ol>
   <div>
    <p>
     <strong>
      Example 1:
     </strong>
    </p>
    <pre>
<strong>Input: </strong><span id="example-input-1-1">5</span>
<strong>Output: </strong><span id="example-output-1">2</span>
<strong>Explanation: </strong>5 is "101" in binary, with complement "010" in binary, which is 2 in base-10.
</pre>
    <div>
     <p>
      <strong>
       Example 2:
      </strong>
     </p>
     <pre>
<strong>Input: </strong><span id="example-input-2-1">7</span>
<strong>Output: </strong><span id="example-output-2">0</span>
<span id="example-output-1"><strong>Explanation: </strong>7 is "111" in binary, with complement "000" in binary, which is 0 in base-10.
</span></pre>
     <div>
      <p>
       <strong>
        Example 3:
       </strong>
      </p>
      <pre>
<strong>Input: </strong><span id="example-input-3-1">10</span>
<strong>Output: </strong><span id="example-output-3">5</span>
<strong>Explanation: </strong>10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10.
</pre>
      <p>
       &nbsp;
      </p>
      <p>
       <strong>
        Note:
       </strong>
      </p>
      <ol>
       <li>
        <code>
         0 &lt;= N &lt; 10^9
        </code>
       </li>
      </ol>
     </div>
    </div>
   </div>
  </div>
  <div>
   <h1 class="question_title">
    1054. 十进制整数的反码
   </h1>
   <p>
    每个非负整数&nbsp;
    <code>
     N
    </code>
    &nbsp;都有其二进制表示。例如，&nbsp;
    <code>
     5
    </code>
    &nbsp;可以被表示为二进制&nbsp;
    <code>
     "101"
    </code>
    ，
    <code>
     11
    </code>
    可以用二进制&nbsp;
    <code>
     "1011"
    </code>
    &nbsp;表示，依此类推。注意，除&nbsp;
    <code>
     N = 0
    </code>
    &nbsp;外，任何二进制表示中都不含前导零。
   </p>
   <p>
    二进制的反码表示是将每个&nbsp;
    <code>
     1
    </code>
    &nbsp;改为&nbsp;
    <code>
     0
    </code>
    &nbsp;且每个&nbsp;
    <code>
     0
    </code>
    &nbsp;变为&nbsp;
    <code>
     1
    </code>
    。例如，二进制数&nbsp;
    <code>
     "101"
    </code>
    &nbsp;的二进制反码为&nbsp;
    <code>
     "010"
    </code>
    。
   </p>
   <p>
    给定十进制数&nbsp;
    <code>
     N
    </code>
    ，返回其二进制表示的反码所对应的十进制整数。
   </p>
   <p>
    &nbsp;
   </p>
   <ol>
   </ol>
   <p>
    <strong>
     示例 1：
    </strong>
   </p>
   <pre><strong>输入：</strong>5
<strong>输出：</strong>2
<strong>解释：</strong>5 的二进制表示为 "101"，其二进制反码为 "010"，也就是十进制中的 2 。
</pre>
   <p>
    <strong>
     示例 2：
    </strong>
   </p>
   <pre><strong>输入：</strong>7
<strong>输出：</strong>0
<strong>解释：</strong>7 的二进制表示为 "111"，其二进制反码为 "000"，也就是十进制中的 0 。
</pre>
   <p>
    <strong>
     示例 3：
    </strong>
   </p>
   <pre><strong>输入：</strong>10
<strong>输出：</strong>5
<strong>解释：</strong>10 的二进制表示为 "1010"，其二进制反码为 "0101"，也就是十进制中的 5 。
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      0 &lt;= N &lt; 10^9
     </code>
    </li>
   </ol>
  </div>
 </body>
</html>